#include "NeoComboBoxPrivate.h"
#include "NeoComboBox.h"
#include <QPropertyAnimation>

NeoComboBoxPrivate::NeoComboBoxPrivate(QObject *parent)
    : QObject(parent),
      pIsShowView(false),
      pFixedSizeAnimation(new QPropertyAnimation(this))
{
    pFixedSizeAnimation->setDuration(400);
    pFixedSizeAnimation->setPropertyName("maximumHeight");
}

NeoComboBoxPrivate::~NeoComboBoxPrivate() = default;

void NeoComboBoxPrivate::startShowPopupAnimation()
{
    NEO_PRIVATE_POINT(NeoComboBox);
    pFixedSizeAnimation->setTargetObject(q->findChild<QFrame *>());
    pFixedSizeAnimation->setStartValue(1);
    pFixedSizeAnimation->setEndValue(150);
    pFixedSizeAnimation->setDirection(QAbstractAnimation::Forward);
    pFixedSizeAnimation->setEasingCurve(QEasingCurve::OutCubic);
    pFixedSizeAnimation->start();
}

void NeoComboBoxPrivate::startHidePopupAnimation()
{
    NEO_PRIVATE_POINT(NeoComboBox);
    pFixedSizeAnimation->setTargetObject(q->findChild<QFrame *>());
    pFixedSizeAnimation->setStartValue(1);
    pFixedSizeAnimation->setEndValue(150);
    pFixedSizeAnimation->setDirection(QAbstractAnimation::Backward);
    pFixedSizeAnimation->setEasingCurve(QEasingCurve::InCubic);
    pFixedSizeAnimation->start();
}